using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;
using WHC.OrderWater.Commons;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// StockDispatchDetail 的摘要说明。
	/// </summary>
	public class StockDispatchDetail : BaseDAL<StockDispatchDetailInfo>, IStockDispatchDetail
	{
		#region 对象实例及构造函数

		public static StockDispatchDetail Instance
		{
			get
			{
				return new StockDispatchDetail();
			}
		}
		public StockDispatchDetail() : base("TB_StockDispatchDetail","ID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override StockDispatchDetailInfo DataReaderToEntity(IDataReader dataReader)
		{
			StockDispatchDetailInfo stockDispatchDetailInfo = new StockDispatchDetailInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			stockDispatchDetailInfo.ID = reader.GetInt32("ID");
			stockDispatchDetailInfo.StorageDispatch_ID = reader.GetInt32("StorageDispatch_ID");
			stockDispatchDetailInfo.ItemNo = reader.GetString("ItemNo");
			stockDispatchDetailInfo.ItemName = reader.GetString("ItemName");
			stockDispatchDetailInfo.Unit = reader.GetString("Unit");
			stockDispatchDetailInfo.Price = reader.GetDecimal("Price");
			stockDispatchDetailInfo.Quantity = reader.GetDouble("Quantity");
			
			return stockDispatchDetailInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(StockDispatchDetailInfo obj)
		{
		    StockDispatchDetailInfo info = obj as StockDispatchDetailInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("StorageDispatch_ID", info.StorageDispatch_ID);
 			hash.Add("ItemNo", info.ItemNo);
 			hash.Add("ItemName", info.ItemName);
 			hash.Add("Unit", info.Unit);
 			hash.Add("Price", info.Price);
 			hash.Add("Quantity", info.Quantity);
 				
			return hash;
		}

    }
}